package com.platform.apex.app;

import org.apache.hadoop.conf.Configuration;

import com.datatorrent.api.DAG;
import com.datatorrent.api.StreamingApplication;
import com.datatorrent.api.annotation.ApplicationAnnotation;
import com.datatorrent.lib.io.ConsoleOutputOperator;
import com.platform.apex.input.MyJdbcStore;
import com.platform.apex.input.MySqlInputOperator;
import com.platform.apex.output.MySqlOutputOperator;

@ApplicationAnnotation(name = "MysqlToMysqlApplicaton")
public class MysqlTomysqlApplication implements StreamingApplication{

	@Override
	public void populateDAG(DAG dag, Configuration conf) {
		loadDag(dag, conf);
		
	}

	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	private void loadDag(DAG dag, Configuration conf) {
		
		MySqlInputOperator fromMysql = dag.addOperator("mysqlInputReader",  MySqlInputOperator.class);
		
		MySqlOutputOperator toMySql = dag.addOperator("mysqlOutputWriter", MySqlOutputOperator.class);
//		ConsoleOutputOperator cons = dag.addOperator("console", new ConsoleOutputOperator());
		
		
//		dag.addStream("mysql-to-console", fromMysql.outputPort, cons.input);
		dag.addStream("mysql-to-console", fromMysql.outputPort, toMySql.input);
		
	}
}
